import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2023-10-16
 * Time: 23:03
 */
public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            Arrays.sort(arr);
            int ans = dfs(arr, 0, arr.length, 0, 1);
            System.out.println(ans);
        }
    }

    private static int dfs(int[] arr, int index, int n, int sum, int mul) {
        int count = 0;
        for (int i = index; i < n; i++) {
            // 选择当前元素
            sum += arr[i];
            mul *= arr[i];
            if (sum > mul) {
                // 当前成立
                count = count + 1 + dfs(arr, i+1, n, sum, mul);
            } else if (sum == mul) {
                // sum == mul 后面可能还有 1, 仍然会成立
                count = count + dfs(arr, i+1, n, sum, mul);
            } else {
                break; // 当前不成立后面就不可能成立
            }
            // 不选择当前元素
            sum -= arr[i];
            mul /= arr[i];
            // 跳过重复的
            while (i < n-1 && arr[i]==arr[i+1]) {
                i++;
            }
        }
        return count;
    }
}